﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            //在D盘下创建mysolo文件夹
            // Directory.CreateDirectory("D:\\");
            // Directory.CreateDirectory("D:\\-1");
            //创建txt文件
            /*FileInfo file = new FileInfo("D:\\mysolo\\test.txt");
            if (!file.Exists )
            {
                file.Create().Close();
                //编写
                string path = "D:\\mysolo\\test.txt";
                StreamWriter streamWriter = new StreamWriter(path);
                streamWriter.WriteLine("佩奇");
                streamWriter.WriteLine ("1425526");
                streamWriter.Flush();
                streamWriter.Close();

            }*/
            //判断mysolo是否存在
            /* bool flag = Directory.Exists("D:\\mysolo");
             if (flag)
             {
                 Directory.Delete("D:\\mysolo",true);//删除文件
             }
             else
             {
                 Directory.CreateDirectory("D:\\mysolo");//创建
                 FileInfo file = new FileInfo("D:\\mysolo\\test.txt");
                 if (!file.Exists)
                 {
                     file.Create().Close();
                     //编写
                     string path = "D:\\mysolo\\test.txt";
                     StreamWriter streamWriter = new StreamWriter(path);
                     streamWriter.WriteLine("佩奇");
                     streamWriter.WriteLine("1425526");
                     streamWriter.Flush();
                     streamWriter.Close();

                 }
             }*/
           
            /*
            //判断目标文件是否存在
            DirectoryInfo directoryInfo = new DirectoryInfo("D:\\");
            IEnumerable<DirectoryInfo> dir = directoryInfo.EnumerateDirectories();
            foreach (var c in dir) {


                if (c.Name== "mysolo")
                {
                    Directory.Delete("D:\\mysolo");

                    Directory.CreateDirectory("D:\\mysolo");
                }
                else
                {
                
                    //在D盘下创建code文件夹
                    Directory.CreateDirectory("D:\\mysolo");
                   
                }
                */
              
              /*  FileInfo fileInfo = new FileInfo("D:\\mysolo\\test.txt");
                if (!fileInfo .Exists)
                {
                    fileInfo.Create().Close();
                   
                }*/
                string path = @"D:\\mysolo\\test.txt";
                StreamWriter streamWriter = new StreamWriter(path);
                streamWriter.WriteLine("hgfsh");
                streamWriter.WriteLine("5454587485212");
                streamWriter.Flush();
                streamWriter.Close();
            }

        }
    }

